<html>
	<head>
		<title></title>

		<script type="text/javascript" src="http://www.google.com/jsapi?key=helloworld"></script>
		<script type="text/javascript">
			google.load("jquery", "1.4.1");
			google.load("dojo", "1.1");
			
			function getMyUserList() {
				var url = 'json/getMyUserList.action';
				var params = {
				};
				jQuery.post(url, params, function(data) {
					var s = "";
					for (var idx = 0; idx < data.length; idx++) {
						s += "user["+idx+"].id=" + data[idx].id + "\n";
					}
					alert(s);
				}, 'json');
			}
			function getMyUserMap() {
				var url = 'json/getMyUserMap.action';
				var params = {
				};
				jQuery.post(url, params, function(data) {
					var s = "";
					for (var o in data) {
						s += "user.id=" + data[o].id + ",";
						s += "user.username=" + data[o].username + "\n";
					}
					alert(s);
				}, 'json');
			}

			function testSmdAction() {
				//create service object(proxy) using SMD (generated by the json result)
				var service = new dojo.rpc.JsonService("/json/smdAction.action");
				
				//execute remote method
				var defered = service.getMyUserList(10);
				
				//attach callback to defered object
				defered.addCallback(function(data) {
					var s = "";
					for (var idx = 0; idx < data.length; idx++) {
						s += "user["+idx+"].id=" + data[idx].id + "\n";
					}
					alert(s);
				});
			}

			function init() {
				dojo.require("dojo.io.script");
				dojo.require("dojo.rpc.JsonService");
			}
		</script>
	</head>

	<body style="margin: 20px;" onload="init();">
		<h3>json test</h3>
		<ul>
			<li><a href="jsonExample1.action">JSON Example1</a></li>
			<li><a href="#" onclick="getMyUserList()">getMyUserList</a></li>
			<li><a href="#" onclick="getMyUserMap()">getMyUserMap</a></li>
			<li><a href="#" onclick="testSmdAction()">SMD Action</a></li>
		</ul>
	</body>
</html>
